import { useSettingStore } from "@/store/setting"
import { generateColors, setColors } from "@/utils/color"

export const useGenerateTheme = () => {
  const settingStore = useSettingStore()

  watchEffect(() => {
    if (settingStore.theme !== settingStore.originalTheme) {
      const colors = {
        primary: settingStore.theme,
        ...generateColors(settingStore.theme)
      }
      setColors(colors)

      settingStore.changeTheme("originalTheme", settingStore.theme)
    }
  })
}
